<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
    function  getThaiMonth($index){
        $array_month = array("มกราคม" , "กุมภาพันธ์" ,"มีนาคมท","เมษายน","พฤษภาคม","มิถุนายน","กรกฏาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม");
        return $array_month[$index-1];
    }
    
    function get_level( $code ){
        $now_year =(  date("Y")+543);
        $ans =( substr($now_year , -2 , 2) - substr($code , 0 , 2))+1;
        return $ans;
    }
    
    function setDate($datetext){
            $datetime = substr($datetext, 0,10);
            $string_date = explode("-", $datetime);
            return $string_date[2] . "-" . $string_date[1] . "-" . $string_date[0];
    }
    
    function gen_page_select_limit($count , $start = 0,$config = array(
        "name" => "page-limit","id" => "page-limit" , "class" => ""  ,"onchange" => ""))
   {
        $limit = 15;
        $start = ($_POST["page-limit"]=="")?0:$_POST["page-limit"];
        $event_change = (trim($config["onchange"])=="")?"  ":"onchange='" . $config["onchange"] . "'  ";
        $count = ceil($count / $limit);
        for($page = 0;$page < $count;$page++){
            $option .= "<option     " . ((($page*$limit)==$_POST["page-limit"])?'selected="selected"':'') ."    value=\""  . ($page*$limit) . "\">หน้าที่ " . ($page+1) . "-" .(($page+1)*15) ."</option>";
        }
        print(
            "<div  style=\"width:94%;text-align:left ;margin: 0 auto\" >
                <select  {$event_change}  name=\"page-limit\"  style=\"width:130px !important\" >
                             {$option}
                </select>
             </div>
           "
        );
    }
    
?>
